﻿@using ChestPainCenterSystem.Areas.ChestPainCenter.Models;
@{
    Layout = null;
    PatientOverview patient = (PatientOverview)@Model;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>患者详情</title>
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/ligerui-icons.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Gray/css/all.css" />
    <link rel="stylesheet" href="~/Content/css/common.css" />
    <script src="~/Scripts/jquery-1.10.2.min.js"  ></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <link rel="stylesheet" href="~/Scripts/laydate/theme/default/laydate.css" />
    <script src="~/Scripts/laydate/laydate.js"></script>
    <style  >
    #tdhelpcont,#tdhelptit{display:none;}
    .tdLeft{width:100px;text-align:right;line-height:30px;}
    .tdRight{width:140px;line-height:30px;}
    .radio_label{display:inline-block;width:auto;height:22px;background:url(/Content/images/radiobutton.png) no-repeat;background-position:-13px -16px;text-indent:22px;line-height:22px;}
    .radio_label:hover{background-position:-13px -116px;}
    .checkbox_label{display:inline-block;width:auto;height:22px;background:url(/Content/images/checkboxbutton.png) no-repeat;background-position:-13px -16px;text-indent:22px;line-height:22px;}
    .checkbox_label:hover{background-position:-13px -116px;}
    .checked{background-position:-13px -216px;}
    .checked:hover{background-position:-13px -216px;}
    input[type=radio]{width:0;}
    input[type=checkbox]{width:0;}
    </style>
</head>
<body>
    <form> 
    <div style="margin:10px 5px;">
        <table border="0">
            <tr>
                <td class="tdLeft">
                    登记时间：
                </td>
                <td class="tdRight">
                    <input type="text" id="txtCreateTime" name="txtCreateTime" class="l-text" maxlength="20" value="@patient.RegisterTime" />
                </td>
                <td class="tdLeft">
                    患者姓名：
                </td>
                <td class="tdRight">
                    <input type="text" id="txtRealName" name="txtRealName" class="l-text" maxlength="10" value="@patient.PATIENT_NAME" />
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    身份证：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtIDCard" name="txtIDCard" class="l-text" maxlength="18" value="@patient.PATIENT_ID_NUM" />
                </td>
                <td class="tdLeft">
                    年龄：
                </td>
                <td class="tdRight">
                    <input type="text" id="txtAge" name="txtAge" class="l-text" maxlength="3" typeof="number" value="@patient.PATIENT_AGE" />
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    联系电话：
                </td>
                <td class="tdRight">
                    <input type="text" id="txtPhoneNum" name="txtPhoneNum" class="l-text" maxlength="14" value="@patient.PATIENT_PHONE" />
                </td>
                <td class="tdLeft">
                    性别：
                </td>
                <td class="tdRight">
                    <label for="eventGrade1">
                        <input type="radio" id="eventGrade1" name="eventGrade" value="0" @(patient.PATIENT_SEX == "男" ? "checked=checked" : "") />&nbsp;男
                    </label>
                    <label for="eventGrade2">
                        <input type="radio" id="eventGrade2" name="eventGrade" value="1" @(patient.PATIENT_SEX == "女" ? "checked=checked" : "") />&nbsp;女
                    </label>
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    住址：
                </td>
                <td colspan="3">
                    <input type="text" id="txtAddress" name="txtAddress" class="l-text" maxlength="50" style="width:370px;" value="@patient.PATIENT_ADDR" />
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    住院ID：
                </td>
                <td class="tdRight">
                    <input type="text" id="txtPATIENT_ID" name="txtPATIENT_ID" class="l-text" maxlength="20" value="@patient.PATIENT_ID" @(!string.IsNullOrWhiteSpace(patient.PATIENT_ID) ? "readonly=readonly" : "") />
                    
                </td>
                <td class="tdLeft">
                    门诊ID：
                </td>
                <td class="tdRight">
                    <input type="text" id="txtHospitalId" name="txtHospitalId" class="l-text" maxlength="20" value="" />
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    呼救：
                </td>
                <td class="tdRight">
                    <label for="rdoHelp1">
                        <input type="radio" id="rdoHelp1" name="rdoHelpList" value="1" @(patient.IsHelp == 1 ? "checked=checked" : "") />是
                    </label>
                    <label for="rdoHelp2">
                        <input type="radio" id="rdoHelp2" name="rdoHelpList" value="0" @(patient.IsHelp != 1 ? "checked=checked" : "") />否
                    </label>
                </td>
                <td class="tdLeft" id="tdhelptit"  >
                    <span>呼救时间：</span>
                </td>
                <td class="tdRight" id="tdhelpcont" >
                    <input type="text" id="txthelpTime" name="txthelpTime" class="l-text" maxlength="20" value="@patient.HelpTime" />
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    发病时间：
                </td>
                <td colspan="3">
                    <input type="text" id="txtillTime" name="txtillTime" class="l-text" maxlength="20" value="@patient.EMS_DISEASE_TIME" />
                </td>               
            </tr>
            <tr>
                <td class="tdLeft">
                    发病地址：
                </td>
                <td colspan="3">
                    <input type="text" id="txtillAddress" name="txtillAddress" />
                </td>
            </tr>
            <tr>
                <td class="tdLeft" style="vertical-align:top;">
                    诊疗路径：
                </td>
                <td colspan="3">
                    <table style="width:100%">
                        <tr>
                            <td style="text-align:left;line-height:30px;">
                                <label for="illestimate1">
                                    <input type="checkbox" id="illestimate1" name="illestimateList" value="1" />&nbsp;胸痛
                                </label>
                            </td>
                            <td style="text-align:left;line-height:30px;">
                                <label for="illestimate2">
                                    <input type="checkbox" id="illestimate2" name="illestimateList" value="2" />&nbsp;脑卒中
                                </label>
                            </td>
                            <td style="text-align:left;line-height:30px;">
                                <label for="illestimate3">
                                    <input type="checkbox" id="illestimate3" name="illestimateList" value="3" />&nbsp;创伤
                                </label>
                            </td>
                        </tr>
                       
                    </table>
                </td>
            </tr>
            <tr>
                <td class="tdLeft">
                    来院方式：
                </td>
                <td class="tdRight" colspan="3">
                    <input id="ddlfromhospitalType" type="text" />
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding-top:20px; text-align:center;">
                    <input type="hidden" id="txtId" name="txtId" value="@patient.ID" />
                    <input id="btnClose" type="button" value="关闭" class="l-button" />
                    <input id="btnSave" type="button" value="保存" class="l-button" />
                </td>
            </tr>
        </table>
    </div>
        </form>
    <script  >
        $(function () {
            //控件初始化
            laydate.render({ elem: '#txtCreateTime', type: 'datetime' });
            laydate.render({ elem: '#txtillTime', type: 'datetime' });
            laydate.render({ elem: "#txthelpTime", type: "datetime" });
            //是否呼救
            $('input[name=rdoHelpList]').click(function () {
                if ($("input[name='rdoHelpList']:checked").val() == 1) {
                    $("#tdhelptit").show();
                    $("#tdhelpcont").show();
                } else {
                    $("#tdhelptit").hide();
                    $("#tdhelpcont").hide();
                }
            });
            //来院方式
            $("#ddlfromhospitalType").ligerComboBox({
                width: 210,
                data: [{ "ID": '0', "Name": "请选择" }, { "ID": 1, "Name": "120" }, { "ID": 2, "Name": "转院" }, { "ID": 3, "Name": "自行来院" }, { "ID": 4, "Name": "院内发病" }],
                isMultiSelect: false,
                valueField: "ID",
                textField: "Name",
                value: '0',
                valueFieldID: 'txtfromhospitalType',
            });
            //发病地址
            $("#txtillAddress").ligerComboBox({
                width: 370,
                isTextBoxMode: true,
                data: [{ "ID": "家中", "Name": "家中" }, { "ID": "户外", "Name": "户外" }, { "ID": "院外", "Name": "院外" }, { "ID": "院内", "Name": "院内" }],
                isMultiSelect: false,
                valueField: "ID",
                textField: "Name",
                value: '0',
                valueFieldID: 'txthdnillAddress',
            });
            //关闭
            $("#btnClose").click(function () {
                parent.window.btnSearch.click();
                frameElement.dialog.close();
            })
            //保存事件
            $("#btnSave").click(function () {
                if ($("#txtIDCard").val() != "") {
                    if ($("#txtRealName").val() == "") { $.ligerDialog.alert("实名制认证患者姓名不能为空"); $("#txtRealName").focus(); return; }
                    if ($("#txtAge").val() == "") { $.ligerDialog.alert("实名制认证患者年龄不能为空"); $("#txtAge").focus(); return; }
                    if ($("#txtPhoneNum").val() == "") { $.ligerDialog.alert("实名制认证患者联系电话不能为空"); $("#txtPhoneNum").focus(); return; }
                    if ($("#txtAddress").val() == "") { $.ligerDialog.alert("实名制认证患者住址不能为空"); $("#txtAddress").focus(); return; }
                }
                $("#txtCreateTime").val(obj2Timemm($("#txtCreateTime").val()));
                $("#txtillTime").val(obj2Timemm($("#txtillTime").val()));
                $("#txthelpTime").val(obj2Timemm($("#txthelpTime").val()));
                var arr = $("form").serializeArray();
                var obj = {};
                for (var i = 0; i < arr.length; i++) {
                    obj[arr[i].name] = arr[i]['value']
                }
                obj["illestimateListArray"] = CheckBoxToArrStr("illestimateList");
                $.post("/ChestPainCenter/PatientList/Save", obj, function (data, textStatus) {
                    if (textStatus == "success") {
                        var d = $.parseJSON(data);
                        if (d.Result == 1) {
                            $.ligerDialog.success("保存成功", function () {
                                parent.window.btnSearch.click();
                                frameElement.dialog.close();
                            });
                        }
                        else if (d.Result == 0) {
                            $.ligerDialog.error(d.Body);
                        }
                        else {
                            $.ligerDialog.error("程序错误");
                        }
                    }
                })
            });
            //纯数字输入框
            $(":text[typeof=number]").keyup(function () {
                var c = $(this);
                if (/[^\d]/.test(c.val())) {
                    var num = c.val().replace(/[^\d]/g, '');
                    $(this).val(num == "" ? "" : parseInt(num));
                }
            })
            //身份证
            $("#txtIDCard").on("blur", function () {
                var val = $(this).val();
                if (val == "") return;
                var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
                if (!idcardReg.test(val)) {
                    $.ligerDialog.error("身份证不合法");
                } else {
                    var bornYear = parseInt(val.substring(6, 10));
                    var nowYear = new Date().getFullYear();
                    $("#txtAge").val((nowYear - bornYear));
                }
            })
            //数据赋值
            //登记时间
            if ($("#txtCreateTime").val() == "") {
                $("#txtCreateTime").val(CurentDateTime());
            }
            else {
                $("#txtCreateTime").val(obj2Timemm($("#txtCreateTime").val()));
            }
            //是否呼救
            if ("@patient.IsHelp" == "1") {
                $("#tdhelptit").show();
                $("#tdhelpcont").show();
            } else {
                $("#tdhelptit").hide();
                $("#tdhelpcont").hide();
            }
            //呼救时间
            if ($("#txthelpTime").val() != "") {
                $("#txthelpTime").val(obj2Timemm($("#txthelpTime").val()));
            }
            //发病时间
            if ($("#txtillTime").val() != "") {
                $("#txtillTime").val(obj2Timemm($("#txtillTime").val()));
            }
            //发病地址
            if ("@patient.EMS_DISEASE_ADDR" != "")
                $("#txtillAddress").ligerGetComboBoxManager().setValue("@patient.EMS_DISEASE_ADDR");
            //病情评估
            if ("@patient.ConditionAssessment" != "")
                CheckBoxSetVal("illestimateList", "@patient.ConditionAssessment",true);
            //来院方式
            if ("@patient.PATIENT_ARRIVE_CLASS" != "")
                $("#ddlfromhospitalType").ligerGetComboBoxManager().setValue("@patient.PATIENT_ARRIVE_CLASS");
            //追加样式
            $("input[type=radio]").parent().addClass("radio_label");
            if (navigator.userAgent.indexOf("Firefox") > 0) { $(":radio,:checkbox").hide(); }
            $("input[type=radio][disabled!=disabled]").click(function () {
                $("input[type=radio][name='" + $(this).attr('name') + "']").parent().removeClass("checked")
                $(this).parent().addClass("checked");
            });
            $("input[type=radio][checked=checked]").parent().addClass("checked");
            $("input[type=checkbox]").parent().addClass("checkbox_label");
            $("input[type=checkbox][disabled!=disabled]").click(function (e) {
                if ($(this).parent().hasClass("checked"))
                    $(this).parent().removeClass("checked");
                else
                    $(this).parent().addClass("checked");
            });
            $("input[type=checkbox][checked=checked]").parent().addClass("checked");
        });
    </script>
</body>
</html>
